#ifndef DIRWATCH_H
#define DIRWATCH_H

#include <QObject>
#include <Windows.h>

#define READ_DIR_CHANGE_BUFFER 4096

class DirWatch : public QObject
{
    Q_OBJECT
public:
    explicit DirWatch(const QString &dir, QObject *parent = 0);
    ~DirWatch() { CloseHandle(m_h); }

signals:
    void fileAdded(const QString &file);
    void fileRemoved(const QString &file);
    void fileRenamed(const QString &oldName, const QString &newName);

public slots:
    void watchDir();

private:
    QString m_dir;
    HANDLE m_h;
    char m_outBuf[READ_DIR_CHANGE_BUFFER];
    DWORD m_bytesRet;
};

#endif // DIRWATCH_H
